<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/admin.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="header">
        <f:event type="preRenderView" listener="#{u_memberManagedBean.fixpage('rights')}"/>
    </ui:define>

    <ui:define name="context">
        <h:form id="formTable" prependId="false">

            <article class="module width_3_quarter">
                <header><h3 class="tabs_involved">Likings Manager</h3></header>

                <div class="tab_container">
                    <div id="tab1" class="tab_content">

                        #{a_rightsManagedBean.set_list()}
                        <p:dataTable id="TableLanguage" var="r" value="#{a_rightsManagedBean.list}" 
                                     paginator="true" rows="15" rowsPerPageTemplate="5,10,15"
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

                            <p:column headerText="Likings" sortBy="name" width="90%">  
                                ${r.name}
                            </p:column>  

                            <p:column headerText="Actions">

                                <p:growl id="msgEdit" showDetail="true" />
                                <p:commandLink id="editLink" oncomplete="PF('editLanguageDialog').show()"
                                               update=":formTable:displayEdit,msgEdit" styleClass="margin-icon">
                                    <h:graphicImage library="admin/images" name="icn_edit.png"/>
                                    <f:setPropertyActionListener value="${r}" 
                                                                 target="#{a_rightsManagedBean.obj}"/>
                                </p:commandLink>

                                <p:commandLink id="removeLink" update="msgEdit,TableLanguage"
                                               actionListener="#{a_rightsManagedBean.remove(r)}">
                                    <h:graphicImage library="admin/images" name="icn_trash.png"/>
                                    <p:confirm header="Confirmation" message="Are you sure ?" 
                                               icon="ui-icon-alert" />
                                </p:commandLink>

                            </p:column>

                        </p:dataTable>

                        <p:dialog id="dlgEdit" header="Language Detail" widgetVar="editLanguageDialog" 
                                  resizable="false"  showEffect="clip" hideEffect="fold" modal="true">
                            <h:panelGrid id="displayEdit" columns="2" cellpadding="4">

                                <h:outputText value="ID" />  
                                <h:outputText value="#{a_rightsManagedBean.obj.id}"/>

                                <h:outputText value="Language" />  
                                <h:inputText value="#{a_rightsManagedBean.obj.name}"/>

                                <p:commandButton id="btnEdit" value="Edit" 
                                                 onclick="PF('editLanguageDialog').hide();"
                                                 actionListener="#{a_rightsManagedBean.edit()}"
                                                 update=":formTable:TableLanguage"/>
                                <p:commandButton value="Cancel" onclick="PF('editLanguageDialog').hide();"/>

                            </h:panelGrid>
                        </p:dialog>

                        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                            <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" 
                                             icon="ui-icon-check"/>  
                            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" 
                                             icon="ui-icon-close"/>       
                        </p:confirmDialog> 

                    </div><!-- end of #tab1 -->

                </div><!-- end of .tab_container -->

            </article><!-- end of content manager article -->

        </h:form>

        <h:form id="formAdd" prependId="false">
            <article class="module width_quarter">
                <header><h3>Add New Rights</h3></header>
                <div class="module_content">
                    <fieldset>
                        <label>Rights</label>
                        <h:inputText id="txtLanguageAdd" value="#{a_rightsManagedBean.name}"/>
                    </fieldset>
                </div>
                <footer>
                    <div class="submit_link">
                        <p:growl id="msgAdd" showDetail="true" />
                        <p:commandButton value="Add" action="#{a_rightsManagedBean.create()}" 
                                         update=":formTable:TableLanguage,msgAdd,txtLanguageAdd"
                                         styleClass="alt_btn"/>
                    </div>
                </footer>
            </article><!-- end of post new article -->
        </h:form>
    </ui:define>

</ui:composition>
